{extend name="public/base" /}
{block name="container"}
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>菜单列表</h5>
                        <div style="float: right;">
                           <a href="{:url('index/nav/create')}"><button type="button" class="btn btn-w-m btn-info">添加菜单</button></a> 
                       </div>
                   </div>
                   <div class="ibox-content">
                    <div class="row">
                        <div class="col-sm-5 m-b-xs">
                        </div>
                        <div class="col-sm-4 m-b-xs">
                        </div>
                        <div class="col-sm-3">
                            <div class="input-group">
                                <input type="text" placeholder="请输入关键词" class="input-sm form-control"> <span class="input-group-btn">
                                    <button type="button" class="btn btn-sm btn-primary"> 搜索</button> </span>
                                </div>
                            </div>
                        </div>
                        <div class="table-responsive">
                            <table class="table table-striped">
                                <thead>
                                    <tr>

                                        <th>序号</th>
                                        <th>菜单名称</th>
                                        <th>菜单链接</th>
                                        <th>状态</th>
                                        <th>操作</th>

                                    </tr>
                                </thead>
                                <tbody>
                                    {volist name="list" id ="vo"}
                                    <tr>
                                        <td>
                                            <input type="checkbox"  class="i-checks" name="input" value="{$vo.id}">{$vo.id}
                                        </td>
                                        <td> <i class="fa {$vo.icon}"></i>--{$vo.menu_name}</td>
                                        <td>{$vo.url}</td>
                                        <td>
                                            {if condition="$vo['status'] eq 1"} 
                                            <i class="glyphicon glyphicon-ok-sign text-success"></i>
                                            {else /}
                                            <i class="glyphicon glyphicon-remove-sign text-danger"></i>
                                            {/if}
                                        </td>
                                        <td>
                                            <a href="{:url('index/nav/update',array('id'=>$vo['id']))}" title="查看"><i class="iconfont icon-chakan"></i></a>
                                            &emsp;
                                            <a href="javascript:;" onclick="delNav({$vo['id']})" title="删除"><i class="iconfont icon-shanchu"></i></a>
                                        </td>
                                    </tr>
                                    {if condition="$vo['child'] neq ''"}
                                    {volist name="$vo['child']" id="cl"}
                                    <tr>
                                        <td>
                                            <input type="checkbox"  class="i-checks" name="input" value="{$vo.id}">{$cl.id}
                                        </td>
                                        <td> &emsp;|---{$cl.menu_name}</td>
                                        <td>{$cl.url}</td>
                                        <td>
                                            {if condition="$cl['status'] eq 1"} 
                                            <i class="glyphicon glyphicon-ok-sign text-success"></i>
                                            {else /}
                                            <i class="glyphicon glyphicon-remove-sign text-danger"></i>
                                            {/if}
                                        </td>
                                        <td>
                                            <a href="{:url('index/nav/update',array('id'=>$cl['id']))}" title="查看"><i class="iconfont icon-chakan"></i></a>
                                            &emsp;
                                            <a href="javascript:;" onclick="delNav({$cl['id']})" title="删除"><i class="iconfont icon-shanchu"></i></a>
                                        </td>
                                    </tr>
                                    {/volist}
                                    {/if} 
                                    {/volist}
                                </tbody>
                            </table>
                            <div style="float: right;">
                             {$page}
                            </div>
                        </div>

                    </div>
                </div>
            </div>

        </div>
    </div>
    {/block}
    {block name="js"}
    <!-- Peity -->
    <script src="__INDEX__/js/plugins/peity/jquery.peity.min.js"></script>

    <!-- 自定义js -->
    <script src="__INDEX__/js/content.js?v=1.0.0"></script>


    <!-- iCheck -->
    <script src="__INDEX__/js/plugins/iCheck/icheck.min.js"></script>

    <!-- Peity -->
    <script src="__INDEX__/js/demo/peity-demo.js"></script>

    <script>
        $(document).ready(function () {
            $('.i-checks').iCheck({
                checkboxClass: 'icheckbox_square-green',
                radioClass: 'iradio_square-green',
            });
        });
    </script>
    <script>
        function delNav(id)
        {
          swal({   
            title: "确定要删除数据?",   
            text: "确认将删除该条数据!",   
            type: "warning",   
            showCancelButton: true,    
            confirmButtonText: "确认", 
            cancelButtonText: '取消',
            closeOnConfirm: false
        }, function(){   
          $.post('{:url("index/nav/delNav")}', {'id':id}, function(data) {
            if(data.sta == -1 ){
                    swal({
                    title: "权限不足",
                    text: "",
                    type: "error"
                });
            }else if(data.sta == 1){
                     swal({
                    title: "删除成功",
                    text: "",
                    type: "success"
                });
                     window.location.reload();
            }else{
                    swal({
                    title: "删除失败",
                    text: "",
                    type: "error"
                });                
            }
          });
      });
      }
  </script>
  {/block}